library(tidyverse)
CFAdata_2<-subset(study2, Obedience>0 & Considerate>0 & Curiosity>0 & Independence>0)




bin.mod <- '
author =~ NA*Obedience + Independence+Considerate+Curiosity'
## Must SIMULTANEOUSLY constrain thresholds, loadings, and intercepts
test.seq <- list(strong = c("thresholds","loadings","intercepts"),
                 means = "means",
                 strict = "residuals")
meq.list <- list()
for (i in 0:length(test.seq)) {
  if (i == 0L) {
    meq.label <- "configural"
    group.equal <- ""
    long.equal <- ""
  } else {
    meq.label <- names(test.seq)[i]
    group.equal <- unlist(test.seq[1:i])
    # long.equal <- unlist(test.seq[1:i])
  }
  
  meq.list[[meq.label]] <- measEq.syntax(configural.model = bin.mod,
                                         data = CFAdata_2,
                                         ordered = c("Obedience",  
                                                     "Independence",
                                                     "Considerate",  
                                                     "Curiosity"),
                                         parameterization = "theta",
                                         ID.fac = "std.lv",
                                         ID.cat = "Wu.Estabrook.2016",
                                         group = "treatment2",
                                         group.equal = group.equal,
                                         #longFacNames = longFacNames,
                                         #long.equal = long.equal,
                                         return.fit = TRUE)
}

summary(compareFit(meq.list))

